<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="author" content="菜鸟开发小组" />
		<meta name="keywords" content="Hyper IT,hyper it,it,hyper,IT 博客,博客,交流平台,IT交流网站,IT服务网站,菜鸟开发小组"/>
		<meta name="description" content="由菜鸟才发小组开发的一个苛求质量的高大上的IT服务网站，为IT技术圈内的大牛与小白提供了一个良好的技术交流平台。"/>
		<meta name="robots" content="all"/>
		<title>Hyper IT</title>
		 
		 <link rel="icon" href="img/logo2.ico" type="image/x-icon"/>
		 <link rel="stylesheet" type="text/css" href="css/newGoods.css" />
		 <link rel="stylesheet" type="text/css" href="css/common.css"/>
		
		 <script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
		 <script type="text/javascript" src="js/goodsList.js"></script>
		 
		 <style>
		 	details summary::-webkit-details-marker { display:none; }
		 </style>
	</head>
	<body>
		<header>
			<div class="wrap">
				<div class="logo">
					<a href="index.html"><img src="img/logo.jpg" width="180" height="50"/></a>
				</div>
			</div>
		</header>
		<div class="main">
			<div class="wrap">
				<aside>
					<details open="open">
						<summary>用户管理</summary>
							<ul>
								<li><a href="allUsers.html">查看所有用户</a></li>
							</ul>
					</details>
					<details open="open">
						<summary>博文管理</summary>
							<ul>
								<li><a href="checkBlog.html">查看博文</a></li>
								<li><a href="checkNote.html">查看随笔</a></li>
							</ul>
					</details>
					<details open="open">
						<summary>商城管理</summary>
							<ul>
								<li><a href="goodsList.html" class="active">查看商品列表</a></li>
								<li><a href="newGoods.html">商品上新</a></li>
								<li><a href="order.html">订单详情</a></li>
							</ul>
					</details>
					<details open="open">
						<summary>职位管理</summary>
							<ul>
								<li><a href="position.html" >查看职位</a></li>
							</ul>
					</details>
					<details open="open">
						<summary>标签管理</summary>
							<ul>
								<li><a href="tag.html">查看标签</a></li>
							</ul>
					</details>
					<details open="open">
						<summary>信息管理</summary>
							<ul>
								<li><a href="infoCenter.html">举报中心</a></li>
							</ul>
					</details>
				</aside>
				<section>
					<div class="info">
							<div class="picture"  >
						 		<img src="img/a86a8cdda8d793745935cdf957594bdc.png" width="150" height="100" id="picture1"/>
									<form id="good_picture">
										<input id="file_upload" type="file" name="file"/>
									</form>
										<div class="image_container">
											<img src=""  id="preview" width="320" height="360" />
										</div>
							</div>
							<div class="info_detail">
								<span>商品名称</span>
								<span><input id="name" type="text"/></span>
								<span>换取H币</span>
								<span>
									<input type="range" max="12000" min="100" value="" 
										id="range1" step="100" onmousemove="anxia1()" style="padding:0;"/>
								</span>
								<output id="num1"> </output>
								<span>库存数量</span>
								<span>
									<input type="range" max="20" min="1" value="" 
										id="range2" step="2" onmousemove="anxia2()" style="padding:0;"/>
								</span>
								<output id="num2"> </output>
							</div>
						<button onclick="updateInfo()">确认修改</button>
					</div>
				</section>
			</div>
		</div>
		<footer>
			<div class="wrap">
				<p>Copyright &copy; 2017-5-5 Hyper IT of 菜鸟开发小组 All Rights Reserved.</p>
			</div>
		</footer>
		
	<script>
		function anxia1 () {
			document.getElementById("num1").innerHTML=document.getElementById("range1").value;
		}
		function anxia2 () {
			document.getElementById("num2").innerHTML=document.getElementById("range2").value;
		}
			function aClick(){
				var id = window.location.href.split('?')[1].split('=')[1];
				var url = "/HyperIT/goods/getonegoods";
				var parm = "id="+id;
				$.get(url,parm,function(data){
					if(data.serviceResult){
						var name = data.resultParm.goods.name;
						var cost = data.resultParm.goods.cost;
						var stock = data.resultParm.goods.stock;
						var path = data.resultParm.goods.path;
						$("#name").val(name);
						$("#num1").html(cost);
						$("#range1").attr('value',cost);
						$("#range2").attr('value',stock);
						$("#num2").html(stock);
						$("#preview").attr('src','..'+path);
					}
					else{
						alert(data.resultInfo);
					}
				});
			}
			aClick();
			
			function updateInfo(){
					var id = window.location.href.split('?')[1].split('=')[1];
					var name = $("#name").val();
					var cost = $("#range1").val();
					var stock = $("#range2").val();
					var formData = new FormData($("#good_picture")[0]);
					formData.append("id",id);
					formData.append("name", name);
					formData.append("cost", cost);
					formData.append("stock",stock);
					$.ajax({
						url: '/HyperIT/goods/updateGoods',
						type: 'POST',
						data: formData,
						async: false,
						cache: false,
						contentType: false,
						processData: false,
						success: function(data) {
							if(data.serviceResult){
								alert("修改成功");
								window.location="goodsList.html";
								
							}else{
								alert(data.resultInfo);
							}
						},
						error: function(data) {
							alert("修改失败！");
						}
					});
			}
	</script>
	</body>
</html>
